//
//  IntegralAmountTableViewController.m
//  GoodWayClient
//
//  Created by HuiDong on 15/12/3.
//  Copyright © 2015年 HuiDong. All rights reserved.
//

#import "IntegralAmountTableViewController.h"
#import "IntegralAmountOtherTableViewCell.h"
#import "ShowMore.h"

@interface IntegralAmountTableViewController ()

@property (weak, nonatomic) IBOutlet UILabel *money;
@property (weak, nonatomic) IBOutlet UILabel *integral;

@property (nonatomic, strong) NSArray *array;
@property (nonatomic, strong) NSMutableArray *arrayAll;

@end

@implementation IntegralAmountTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //对money及integral进行赋值
    self.money.text = @"1000";
    self.integral.text = @"100";
    
    //footView的加载更多的显示
    ShowMore *showMore = [ShowMore footView];
    
    __weak IntegralAmountTableViewController *tempController = self;
    
    ShowMoreBlock block = ^{
        [tempController.arrayAll addObjectsFromArray:tempController.array];
        [tempController.tableView reloadData];
    };
    
    showMore.block = block;
    self.tableView.tableFooterView = showMore;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}



//懒加载
- (NSArray *)array
{
    if (!_array) {
        _array = @[@{@"reason":@"推荐蓝天使者",@"achieve":@"获得1000元和1000积分",@"time":@"2015.11.18"},@{@"reason":@"推荐蓝天使者",@"achieve":@"获得1000元和1000积分",@"time":@"2015.11.18"},@{@"reason":@"推荐蓝天使者",@"achieve":@"获得1000元和1000积分",@"time":@"2015.11.18"},@{@"reason":@"推荐蓝天使者",@"achieve":@"获得1000元和1000积分",@"time":@"2015.11.18"}];
    }
    return _array;
}

- (NSMutableArray *)arrayAll
{
    if (!_arrayAll) {
        _arrayAll = [NSMutableArray arrayWithArray:self.array];
    }
    return _arrayAll;
}


//数据源方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.arrayAll.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        IntegralAmountOtherTableViewCell *cell = [IntegralAmountOtherTableViewCell IntegralAmountOtherWithTableView:tableView];
        cell.dic = self.arrayAll[indexPath.row];
        return cell;
}

//设计行高
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 65;
}

@end
